<jsp:include page="modules/header.jsp">
    <jsp:param name="active" value="home"/>
    <jsp:param name="webTitle" value="Manage WareHouse"/>
</jsp:include>

<%@page import="java.sql.*,java.util.*" %>

<script type="text/JavaScript">
    function loadXMLDoc(url)
    {
        if (window.XMLHttpRequest)
        {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp=new XMLHttpRequest();
        }
        else
        {// code for IE6, IE5
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        var _ID = document.getElementById("fileUpImage").value;
        //_image = "\\img\\" + _fileUp;
        xmlhttp.open("GET",url+"?id="+_ID,false);

        xmlhttp.send(null);
        document.getElementById('info').innerHTML=xmlhttp.responseText;
    }

    function goTo(url){
        window.location = url;
    }

</script>

<div id="page">

    <%
            hbPackage.DatabaseAccess _da = new hbPackage.DatabaseAccess();

            ArrayList arr = _da.getListItem();

    %>

    <form action="../fillStockSvl" method="POST">

        Item Name:
        <select name="dpd_itemName" id="fileUpImage" onchange="loadXMLDoc('itemInfo.jsp')">
            <option>Choose one item</option>
            <% for (int i = 0; i < arr.size(); i++) {
                hbPackage.itemClass _item = (hbPackage.itemClass) arr.get(i);
            %>

            <option value="<%= _item.getId()%>" ><%= _item.getItemName()%></option>

            <% }%>
        </select>

        <div id="info" style="height:auto;width:auto;">
        </div>        

        Quantity <input type="text" name="txt_quantity" value="" maxlength="2" size="2"/>
        <input type="hidden" value="2" name="hid_storeID" />
        <input type="submit" value="Add" />
    </form>
    <%
            //ArrayList orderDetailList = (ArrayList) session.getAttribute("orderDetailList");

            ArrayList arrWareHouse = _da.getWareHouseList(2);

            if (arrWareHouse != null) {
    %>

    <table>
        <tr>
            <th> Item Name </th>
            <th> Quantity </th>
            <th> Price </th>                        
            <th> Update </th>
        </tr>
        <% for (int i = 0; i < arrWareHouse.size(); i++) {
                    hbPackage.wareHouseClass _wareHouse = (hbPackage.wareHouseClass) arrWareHouse.get(i);
                    hbPackage.itemClass _item = _da.getItem(_wareHouse.getItem_ID());
        %>
        <tr>
            <td><%= _item.getItemName() %></td>
            <td><%= _wareHouse.getQuantity() %></td>
            <td><%= _item.getPrice() %></td>
            <td>btnUpdate</td>
        </tr>

        <%
                }//close loop
%>
    </table>    
    <%
            } //close table
%>


</div>